package com.ares.aler.controllr;

import com.ares.aler.entiy.UserPo;
import com.ares.aler.service.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class UserController {

    @Autowired
    UserDao userDao;

    /**
     * 测试用  没有实际使用
     *
     * @return
     */
    @RequestMapping("userSelect")
    public List userSelect() {
        String id = "" ;
        List<UserPo> mapList = new ArrayList<>();
        UserPo userPo = userDao.selectById(id);
        mapList.add(userPo);
        return mapList;
    }

    /**
     * 查询用户展示页面 for table
     * @param page
     * @param limit
     * @return
     */
    @RequestMapping("userAllTable")
    public Map userAllTable(int page,int limit){
        return userDao.selectAllMap(page, limit);
    }

    /**
     * 添加用户
     * @param userPo
     * @return
     */
    @RequestMapping("userSave")
    public Object userSave(UserPo userPo){
        userDao.seveUserPo(userPo);
        Map<String,String>oMap = new HashMap<>();
        oMap.put("rs","200");
        return  oMap;

    }


}
